// 引入Vuex
import Vuex from 'vuex';
import Vue from 'vue';

Vue.use(Vuex);

// 创建store, 并暴露store
var Store = new Vuex.Store({
   state: {
      name: '',//前端用户身份标识, 默认为空，即未登录
   },
   mutations: {
      setName(state, name) {
         state.name = name;
      },
   },
   actions: {
      updateUserInfo({commit}, {name}) {
         commit('setName', name);
      }
   },
   getters: {
      name: (state)=> state.name,
   },
})

export default Store;